﻿{include file=comm/head.html}
{include file=comm/top.html}
<div class="section">
    <div class="container">
        <div class="ct2 clearfix">
            {include file=comm/left.html}
            <div class="ct2-mn">
                {include file=comm/position.html}
                <div class="content-body">
                    <div class="m-message">
                        <form id="myform1" method="post" onsubmit="return submsg(this);">
                            <label> <span>留言标题：</span>
                                <input class="inp" type="text" name="titles" placeholder="请输入标题">
                                <em>*</em> </label>
                            <label> <span>你的姓名：</span>
                                <input class="inp" type="text" name="name" placeholder="请输入你的姓名">
                                <em>*</em>
                            </label>
                            <label> <span>联系电话：</span>
                                <input class="inp" type="text" name="phone" placeholder="请输入你的电话">
                                <em>*</em> 
                            </label>
                            <label> <span>电子邮箱：</span>
                                <input class="inp" type="email" name="email" placeholder="请输入你的邮箱">
                            </label>
                            <label> <span>联系地址：</span>
                                <input class="inp" type="text" name="address" placeholder="请输入你的地址">
                            </label>
                            <label class="mes"> <span>留言内容：</span>
                                <textarea name="content"></textarea>
                            </label>
                            {pboot:if({pboot:msgcodestatus})}
                            <label class="code">
                                <span>验证码：</span>
                                <input type="text" id="vdcode" name="checkcode">
                                <div class="pic"> <img class="img" id="vdimgck" align="absmiddle" onclick="this.src='{pboot:checkcode}?'+Math.round(Math.random()*10);" style="cursor: pointer;height:35px; width:100px;" alt="看不清？点击更换" src="{pboot:checkcode}" /></div>
                            </label>
                            {/pboot:if}
                            <div class="btn-1">
                                <input class="focus" type="submit" value="提交">
                                <input type="reset" value="重置">
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
//ajax提交留言
function submsg(obj){
  var url='{pboot:msgaction}';
  var titles=$(obj).find('input[name="titles"]').val();
  var name=$(obj).find('input[name="name"]').val();
  var phone=$(obj).find('input[name="phone"]').val();
  var email=$(obj).find('input[name="email"]').val();
  var address=$(obj).find('input[name="address"]').val();
  var content=$(obj).find('textarea[name="content"]').val();
  var checkcode=$(obj).find('input[name="checkcode"]').val();
  $.ajax({
    type: 'POST',
    url: url,
    dataType: 'json',
    data: {
        titles: titles,
        name: name,
        phone: phone,
        email: email,
        address: address,
        content: content,
        checkcode: checkcode
    },
    success: function (response, status) {
      if(response.code){
         alert("留言提交成功，我们会尽快联系您！");
         $(obj)[0].reset(); 
      }else{
         alert(response.data);
      }
    },
    error:function(xhr,status,error){
      alert('返回数据异常！');
    }
  });
  return false;
}
</script>
{include file=comm/foot.html}